package com.niit.controller;



import com.niit.dao.TestInDao;
import com.niit.model.StudentPaperQuestionAnswer;
import com.niit.service.TestInService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "学生模块",tags = {"学生模块"})
@RestController
public class TestInController {
    @Autowired
    private TestInService testInService;

    @Autowired
    private TestInDao dao;

    @ApiOperation("获得学生答题信息")
    @PostMapping("/testIn")
    public String add(@RequestBody StudentPaperQuestionAnswer studentPaperQuestionAnswer) {
        return testInService.addStudentPaperQuestionAnswer(studentPaperQuestionAnswer) > 0 ? "success" : "fail";
    }

    @ApiOperation("更新答题信息")
    @PutMapping("/testIn")
    public String update(@RequestBody StudentPaperQuestionAnswer studentPaperQuestionAnswer) {
        return testInService.upStudentPaperQuestionAnswer(studentPaperQuestionAnswer) > 0 ? "success" : "fail";
    }
    @ApiOperation("根据ID查找答题信息")
    @GetMapping("/testIn/{id1}/{id2}")
    public StudentPaperQuestionAnswer select(@PathVariable("id1")Long id1,@PathVariable("id2")Long id2){
        return  testInService.seStudentPaperQuestionAnswer(id1,id2);
    }

    @ApiOperation("根据paperID查找答题信息列表")
    @GetMapping("/testInp/{id2}}")
    public List<StudentPaperQuestionAnswer> select(@PathVariable("id2")Long id2){
        return  testInService.selectStudentPaperQuestionAnswerForPaper(id2);
    }
}


